-- card: 3972 from stack: in.2 -- bmap block id: 4348 -- flags: 0000 -- background id: 2812 -- name: Try it out! ----- HyperTalk script ----- on openCard hide card field "Button ID" end openCard on closeCard -- If there is already a DA-launching button on this card, -- then delete it if card field "Button ID" is not empty and the number of card buttons > 3 then set cursor to 4 set lockScreen to true choose button tool -- Get the ID of the button we've created (which has been -- placed in the hidden card field, "Button ID"), and use -- this ID to locate and delete the button. click at the loc of -- card button ID (item 1 of card field "Button ID") -- doMenu "Clear button" choose browse tool set lockScreen to false end if put empty into card field "Button ID" put empty into card field "Sample DA menu" put empty into card field "Show DA names" end closeCard -- part 1 (field) -- low flags: 01 -- high flags: 0000 -- rect: left=369 top=250 right=304 bottom=499 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Sample DA menu ----- HyperTalk script ----- on mouseUp -- Find out which line the user has clicked on get clickline() put it into theLineClickedOn -- Highlight the line select line theLineClickedOn of card field "Sample DA menu" -- Clear the highlighting wait 20 ticks click at 0,0 -- Put the contents of this line into a container put line theLineClickedOn of card field "Sample DA menu" into theDAtoLaunch -- If this container contains the valid name of a DA, -- then launch that DA if theDAtoLaunch is not empty then if theDAtoLaunch contains "…" then answer "This DA name is truncated--I can't launch it." with "Sorry" else doMenu theDAtoLaunch end if end if end mouseUp -- The following function is taken directly from Apple's -- documentation for the HyperCard 1.2 release --function clickLine returns the line of the target field --over which the mouse was clicked. It allows 4 pixels under the --baseline for the psychological effect of descenders. function clickLine return ((the mouseV - item 2 of the rect of the target-4) div the textheight of the target) + 1 end clickLine -- part 2 (button) -- low flags: 00 -- high flags: 8002 -- rect: left=20 top=116 right=137 bottom=116 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 21 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: getDANames ----- HyperTalk script ----- on mouseUp set cursor to 4 -- watch cursor put empty into card field "Show DA names" -- The GetDANames XCMD will put the names of the DAs in the -- Apple menu in the form of a comma-delimited item list -- into the container, "namesOfDAs" GetDANames -- Put the contents of this container into the card field put namesOfDAs into card field "Show DA names" end mouseUp -- part 3 (field) -- low flags: 00 -- high flags: 0007 -- rect: left=134 top=116 right=185 bottom=499 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 21 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Show DA names -- part 4 (button) -- low flags: 00 -- high flags: 8002 -- rect: left=238 top=229 right=249 bottom=339 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 21 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Make a DA list ----- HyperTalk script ----- on mouseUp set cursor to 4 -- watch cursor -- Clear the contents of the sample DA menu put empty into card field "Sample DA menu" -- Put the list of the names of the DAs in the apple menu into -- the container, "namesOfDAs" GetDANames -- Use James L. Paul's DoList (ListManager) routine to display a list -- of DAs, from which one can select a DA to launch DoList "Select","Cancel",namesOfDAs,one -- If the user selected a DA name, then launch that DA if the result is not empty then put item 2 of the result into theDAtoOpen doMenu theDAtoOpen -- Otherwise put the names of the first three DAs into the -- sample menu to the right else -- Put the first three names of DAs into the sample DA menu -- next to this button -- Make a sample DA menu with up to three choices, depending -- on the number of DAs in the Apple menu -- (The numberOfDAs function is in the stack script) if numberOfDAs() > 3 then put 3 into theNumberOfDAs -- Put the names of these DAs into the sample menu -- (The truncateAt15Chars function is in the stack script) repeat with theCount = 1 to theNumberOfDAs put truncateAt15Chars(item theCount of namesOfDAs) into line theCount of card field "Sample DA menu" end repeat end if end mouseUp -- part 5 (button) -- low flags: 00 -- high flags: 8002 -- rect: left=20 top=229 right=249 bottom=126 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 21 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Make a DA button ----- HyperTalk script ----- on mouseUp -- Display the watch cursor set cursor to 4 -- Get the names of the DAs, putting these into the container -- "namesOfDAs" in item list format getDANames -- Ask for the name of a desk accessory -- See James L. Paul's "HyperList" stack for more -- information about the DoList command DoList "Select","Cancel",namesOfDAs,one -- If a choice was made, then put the name of the item chosen -- into a temporary variable; otherwise exit this script if the result > 0 then put item 2 of the result into daName else exit mouseUp end if -- "Freeze" the screen while a button is being made and displayed set lockScreen to true -- If there is already a DA-launching button on this card, -- then delete it if card field "Button ID" is not empty and the number of card buttons > 3 then put item 1 of card field "Button ID" into buttonID choose button tool click at the loc of card button ID buttonID doMenu "Clear button" choose browse tool end if -- Make the new button doMenu "New Button" hide button "New Button" put daName into nameOfButton set name of button "New Button" to nameOfButton -- Use the suitcase icon for DAs which has been pasted into -- this stack, and given the name "DA suitcase" set icon of button nameOfButton to "DA suitcase" set style of button nameOfButton to shadow put 135 into leftSide put 235 into topSide set rect of button nameOfButton to leftSide, topSide, leftSide + 90, topSide + 60 -- Store the button ID of the newly-created button, so -- that it can be deleted later put ID of button nameOfButton into card field "Button ID" -- Construct the script for the new button and place it -- into the button's script put "on mouseUp" & return into buttonScript put "doMenu" && quote & daName & quote & Return after buttonScript put "end mouseUp" & Return after buttonScript set script of button nameOfButton to buttonScript -- Clean up things and flash the newly-created button show button nameOfButton choose browse tool set lockScreen to false repeat 2 set the hilite of button nameOfButton to true set the hilite of button nameOfButton to false end repeat end mouseUp -- part 8 (field) -- low flags: 81 -- high flags: 0000 -- rect: left=73 top=61 right=80 bottom=144 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Button ID -- part 32 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=365 top=222 right=247 bottom=500 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Make sample DA menu ----- HyperTalk script ----- on mouseUp -- Clear out the last entries used put empty into card field "Sample DA menu" -- Get the names of the DAs in the Apple menu GetDANames -- Put the first three names of DAs into the sample DA menu -- under this button -- Make a sample DA menu with up to three choices, depending -- on the number of DAs in the Apple menu -- (The numberOfDAs function is in the stack script) if numberOfDAs() > 3 then put 3 into theNumberOfDAs -- Put the names of these DAs into the sample menu -- (The truncateAt15Chars function is in the stack script) repeat with theCount = 1 to theNumberOfDAs put truncateAt15Chars(item theCount of namesOfDAs) into line theCount of card field "Sample DA menu" end repeat end mouseUp -- part contents for card part 3 ----- text ----- Suitcase II,Acta,Alarm Clock,Art Grabber+™,Async AppleTalk,Calculator,CD Remote,Chooser,Control Panel,DeskDraw™,DeskPaint™ ,DiskTop ------>,Display RLE Image,Guidance,HD Partition,HyperDA,Icon Maker 2.1,Key Caps,McSink------>,QuickMail,SmartScrap™,Thunder -- part contents for card part 1 ----- text ----- Suitcase II Acta Alarm Clock -- part contents for card part 8 ----- text ----- 36